var form = document.querySelector('form')
var tips = document.querySelectorAll('.tips')
const loginBtn = document.getElementById('loginBtn')
const username = document.getElementById('username')
const password = document.getElementById('password')
const box = document.querySelector('.box');
loginBtn.onclick = function () {
    ajax({
        url: '../php/login.php',
        type: 'post',
        data: {
            "username": username.value,
            "password": password.value,
        },
        dataType: 'json',
        success: function (res) {
            // code为代表成功 其他代表失败
            if (res.code == 1) {
                // 把后端返回的token存到cookie里面

                location.href = './index.html'
            } else {
                tips[2].style.display = 'block'
            }

        }
    })

}